package com.yk.framework.gui.core.impl;

import com.yk.framework.entity.ICoreBaseInfo;
import com.yk.framework.gui.ctrl.model.IF6Format;

/**
 * @author lifetime
 * 
 */
public class DefaultF6Format implements IF6Format {
	private Object userObject;
	private String editFormatStr;
	private String displayFormatStr;

	public DefaultF6Format() {
	}

	public DefaultF6Format(String displayFormatStr, String editFormatStr) {
		this.displayFormatStr = displayFormatStr;
		this.editFormatStr = editFormatStr;
	}

	public Object getUserObject() {
		return userObject;
	}

	public void setUserObject(Object obj) {
		userObject = obj;
	}

	public String getDispalyText() {
		if (userObject instanceof ICoreBaseInfo) {
			ICoreBaseInfo baseInfo = (ICoreBaseInfo) userObject;
			if (baseInfo.containKey(displayFormatStr)) {
				return baseInfo.getString(displayFormatStr);
			}
		}
		return userObject != null ? userObject.toString() : null;
	}

	public String getEditText() {
		if (userObject instanceof ICoreBaseInfo) {
			ICoreBaseInfo baseInfo = (ICoreBaseInfo) userObject;
			if (baseInfo.containKey(editFormatStr)) {
				return baseInfo.getString(editFormatStr);
			}
		}
		return userObject != null ? userObject.toString() : null;
	}

	public String getEditFormatStr() {
		return editFormatStr;
	}

	public void setEditFormatStr(String editFormatStr) {
		this.editFormatStr = editFormatStr;
	}

	public String getDisplayFormatStr() {
		return displayFormatStr;
	}

	public void setDisplayFormatStr(String displayFormatStr) {
		this.displayFormatStr = displayFormatStr;
	}

}
